package cn.tedu.lucky.draw.server.service.impl;

import cn.tedu.lucky.draw.server.common.enums.ErrorEnum;
import cn.tedu.lucky.draw.server.common.handler.DrawException;
import cn.tedu.lucky.draw.server.protocol.po.ActivityRule;
import cn.tedu.lucky.draw.server.repository.ActivityRuleRepository;
import cn.tedu.lucky.draw.server.service.IActivityRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityRuleServiceImpl implements IActivityRuleService {

    @Autowired
    private ActivityRuleRepository activityRuleRepository;

    @Override
    public void saveAll(List<ActivityRule> activityRuleList) {
        List<ActivityRule> activityRules = activityRuleRepository.saveAll(activityRuleList);
        if (activityRules==null || activityRules.isEmpty()){
            throw new DrawException(ErrorEnum.SYSTEM_ERROR);
        }
    }
}
